from selenium import webdriver
from selenium.webdriver.common.by import By
from time import sleep

driver = webdriver.Firefox()
url = 'file:///C:/Users/tedu/Desktop/NSD2406/html/registerA.html'
driver.get(url)

# 通过XPATH定位用户名文本框
# / 绝对路径：一层一层的查找
# // 相对路径：可以跨越多层
# username = driver.find_element(By.XPATH, '/html/body/form/div/fieldset/p[1]/input')
# 通过下标定位第n个，还可以通过属性定位
username = driver.find_element(By.XPATH, '/html/body/form/div/fieldset/p[@id="p1"]/input')
username.send_keys('admin')
# 通过XPATH定位密码框输入
# password = driver.find_element(By.XPATH, '//p[2]/input')
password = driver.find_element(By.XPATH, '//*[@placeholder="账号A"]')
password.send_keys('123456')
sleep(3)
driver.quit()